﻿using System; 
using System.IO; 

namespace NTTDATA.BEENChina.CaseMonitor.Log
{
    public class Console
    {

        // public static log4net.ILog log ;
       // private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private static readonly log4net.ILog log = log4net.LogManager.GetLogger("log4netToFile"); 

        public static void Error(string message, Exception ex)
        {
            log.Error(message, ex);
        }

        public static void Error(string message)
        {
            log.Error(message);
        }

        public static void Info(string message, Exception ex)
        {
            log.Info(message, ex);
        }
        public static void Info(string message)
        {
            log.Info(message);
        }

        public static void Warn(string message, Exception ex)
        {
            log.Warn(message, ex);
        }

        public static void Warn(string message)
        {
            log.Warn(message);
        }

        public static void Fatal(string message, Exception ex)
        {
            log.Fatal(message, ex);
        }

        public static void Fatal(string message)
        {
            log.Fatal(message);
        }


        public static void Debug(string message, Exception ex)
        {
            log.Debug(message, ex);
        }

        public static void Debug(string message)
        {
            log.Debug(message);
        }

        public static void initLog4Net()
        {
            //注意这里不写全路径可能导致无法找到配置文件
            FileInfo file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
            if (File.Exists(file.ToString()))
            {
                log4net.Config.XmlConfigurator.Configure(file);
            }
            else
            {
                throw new Exception("log4net日志配置文件未找到");
            }
        }


    }
}
